from typing import List, Dict, Tuple
from .authorization_service import AuthorizationService

auth_service = AuthorizationService()

def apply_indicator_permissions(user_id: str, indicators: List[Dict]) -> Tuple[List[Dict], List[Dict], str]:
    # 检查用户对匹配指标的权限
    authorized, unauthorized, err = auth_service.check_indicator_permissions(user_id, indicators)
    if not authorized:
        return [], indicators, "用户对所匹配的指标均无权限"
    return authorized, unauthorized, ""

def get_authorized_dimensions_and_filters(auth_ids: List[int]) -> Tuple[List[Dict], List[Dict], str]:
    # 获取用户有权限的维度和过滤条件
    return auth_service.get_authorized_dimensions_and_filters(auth_ids)

def compute_filter_intersection(service_filters, client_filters) -> Tuple[List[Dict], str]:
    # 计算服务端和客户端的过滤条件交集
    return auth_service.compute_filter_intersection(service_filters, client_filters)
    
